import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:数组中最长连续子列
 * User: wangxin
 * Date: 2024-07-24
 * Time: 15:37
 */
public class test1 {
    public int MLS (int[] arr) {
        // write code here
        if(arr == null||arr.length ==0){
            return 0;
        }
        Arrays.sort(arr);
        int maxLength1 = 1;
        int maxLength2 = 1;
        for(int i = 0;i < arr.length - 1;i++){
            if(arr[i] == arr[ i + 1]){
                continue;
            }
            if(arr[i + 1] - arr[i ] == 1){
                maxLength1++;
            }
            else{

                maxLength1 = 1;
            }
            maxLength2 = Math.max(maxLength1,maxLength2);
        }
        return maxLength2;
    }
}
